package com.fh.controller.system.user;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.codehaus.jackson.map.util.JSONPObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.fh.controller.base.BaseController;
import com.fh.service.system.user.UserManager;
import com.fh.util.PageData;

 
@Controller
public class TestController extends BaseController  {

	@Resource(name="userService")
	private UserManager userService;
	
	@RequestMapping("/Test_ToTest")
	public ModelAndView ToTest()
	{
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/system/user/test");
		return mv;
	}
	
	/**请求登录，验证用户
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/login_login1" ,produces="application/json;charset=UTF-8")
	@ResponseBody
	public Object login()throws Exception{
		Map<String,String> map = new HashMap<String,String>();
		PageData pd = new PageData();
    	pd = this.getPageData();
//		
    	pd.put("USERNAME", "admin");
//		String keyData = pd.getString("KEYDATA");
    	
    	logBefore(logger, "测试登录系统");
		 
		
     	pd = userService.findByUsername(pd);	//根据用户名和密码去读取用户信息
		
     	if(pd!=null)
     	{
     		map.put("result1", "yes");
     	}
     	
		map.put("result", "11");
		return new JSONPObject("ttt", map);
		//return AppUtil.returnObject(new PageData(), map);
	}
}
